From 6d35f0f0cf072fe6313e6cc90ad5ed314a05e0c4 Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Thu, 27 Nov 2014 14:02:45 +0100 Subject: [PATCH] x86: disable VPMU for PVH guests Currently when VPMU is enabled on a system both HVM and PVH VPCUs will initialize their VPMUs, including setting up vpmu_ops. As result even though VPMU will not work for PVH guests (APIC is not supported there), the guest may decide to perform a write to a PMU MSR. This will cause a call to is_vlapic_lvtpc_enabled() which will crash the hypervisor, e.g.: (XEN) Xen call trace: (XEN) [] is_vlapic_lvtpc_enabled+0x13/0x22 (XEN) [] core2_vpmu_do_wrmsr+0x415/0x589 (XEN) [] vpmu_do_wrmsr+0x2a/0x33 (XEN) [] vmx_msr_write_intercept+0x268/0x557 (XEN) [] hvm_msr_write_intercept+0x36c/0x39b (XEN) [] vmx_vmexit_handler+0x1082/0x185b (XEN) [] vmx_asm_vmexit_handler+0x41/0xc0 If we prevent VPMU from being initialized on PVH guests we will avoid those accesses. Signed-off-by: Boris Ostrovsky Release-Acked-by: Konrad Rzeszutek Wilk --- xen/arch/x86/hvm/vpmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c index 265fc0ecbb..1df74c2947 100644 --- a/xen/arch/x86/hvm/vpmu.c +++ b/xen/arch/x86/hvm/vpmu.c @@ -219,6 +219,9 @@ void vpmu_initialise(struct vcpu *v) struct vpmu_struct *vpmu = vcpu_vpmu(v); uint8_t vendor = current_cpu_data.x86_vendor; + if ( is_pvh_vcpu(v) ) + return; + if ( vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) ) vpmu_destroy(v); vpmu_clear(vpmu); -- 2.30.2